Ext.onReady(function(){ 

Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'under';

var addIDTypeStore=new Ext.data.Store({ 
	proxy:new Ext.data.HttpProxy({
	url:'showType.do?type=CertType',
	method:'GET'
	}), 
	reader:new Ext.data.JsonReader({ },[
	{name:'name'}, 
	{name:'code'}
	]) ,
	autoLoad:true
}); 

var addSexTypeStore=new Ext.data.Store({ 
	proxy:new Ext.data.HttpProxy({
	url:'showType.do?type=SexType',
	method:'GET'
	}), 
	reader:new Ext.data.JsonReader({ },[
	{name:'name'}, 
	{name:'code'}
	]) ,
	autoLoad:true
}); 
var yesOrNoStore=new Ext.data.Store({ 
	proxy:new Ext.data.HttpProxy({
	url:'showType.do?type=YesNo',
	method:'GET'
	}), 
	reader:new Ext.data.JsonReader({ },[
	{name:'name'}, 
	{name:'code'}
	]) ,
	autoLoad:true
}); 

var addDegreeStore=new Ext.data.Store({ 
	proxy:new Ext.data.HttpProxy({
	url:'showType.do?type=DEGREE',
	method:'GET'
	}), 
	reader:new Ext.data.JsonReader({ },[
	{name:'name'}, 
	{name:'code'}
	]) ,
	autoLoad:true
});

var addGradeStore=new Ext.data.Store({ 
	proxy:new Ext.data.HttpProxy({
	url:'showType.do?type=GRADE',
	method:'GET'
	}), 
	reader:new Ext.data.JsonReader({ },[
	{name:'name'}, 
	{name:'code'}
	]) ,
	autoLoad:true
}); 

var addMstatusStore=new Ext.data.Store({ 
	proxy:new Ext.data.HttpProxy({
	url:'showType.do?type=Mstatus',
	method:'GET'
	}), 
	reader:new Ext.data.JsonReader({ },[
	{name:'name'}, 
	{name:'code'}
	]) ,
	autoLoad:true
});


//客户基本信息
var addForm = new Ext.form.FormPanel({ 
id: 'addForm', 
title: '客户基本信息', 
renderTo:"list",
height: 500, 
//样式 
bodyStyle: 'margin:5px;text-align:left;padding:5px 60px;', 
frame: true, 
xtype: 'filedset', 
labelWidth: 100, 
items: 
[ { xtype: 'fieldset', 
collapsible: true, 
autoHeight: true, 
autoWidth: true, 
items: 
[
	{layout:"column",
		items:[{
			columnWidth : .5, // 该列有整行中所占百分比
		           layout : "form",
		           items : [{
		        	   xtype: 'textfield', 
		       		id:'custId',
		       		name: 'custId', 
		       		fieldLabel: '客户编号', 
		       		readOnly:true,
		       		hidden:true,
		       		width: 200
		}
		]},{
			columnWidth : .5, // 该列有整行中所占百分比
		           layout : "form",
		           items : [{		
		}
		]} 
]},	
{layout:"column",
	items:[{
		columnWidth : .5, // 该列有整行中所占百分比
	           layout : "form",
	           items : [{
	        	   xtype: 'textfield', 
	       		id:'custNo',
	       		name: 'custNo', 
	       		fieldLabel: '客户号', 
	       		width: 200
	}
	]},{
		columnWidth : .5, // 该列有整行中所占百分比
	           layout : "form",
	           items : [{
	        	   xtype: 'textfield', 
	        		id:'custName',
	        		name: 'custName', 
	        		fieldLabel: '客户名称', 
	        		readOnly:true,
	        		width: 200   		
	}
	]} 
]},	
	
{layout:"column",
items:[{
	columnWidth : .5, // 该列有整行中所占百分比
           layout : "form",
           items : [{
        	   xtype: 'combo', 
      		 id : "idtype",
      		              store :addIDTypeStore,
      		              fieldLabel: '证件类别',
      		              valueField : 'code',
      		              displayField : 'name',
      		              typeAhead : true,
      		              width: 200,
      		              readOnly:true,
      		              mode:'remote', 
      		              emptyText : '请选择证件类别...',
      		              editable: false,
      		              triggerAction : 'all',
      		              selectOnFocus : true,
      		              hiddenName:'idtype'
}
]},{
	columnWidth : .5, // 该列有整行中所占百分比
           layout : "form",
           items : [{
xtype: 'textfield', 
	id:'idno',
	name: 'idno', 
	fieldLabel: '证件号码', 
	readOnly:true,
	width: 200
}
]} 
]},{
layout:"column",
items:[{
	columnWidth : .5, // 该列有整行中所占百分比
           layout : "form",
           items : [{
        	   xtype: 'combo', 
        		 id : "sexType",
        		              store :addSexTypeStore,
        		              fieldLabel: '性别',
        		              valueField : 'code',
        		              displayField : 'name',
        		              typeAhead : true,
        		              width: 200,
        		              mode:'remote', 
        		              emptyText : '请选择性别...',
        		              editable: false,
        		              allowBlank : false,
        		              blankText:'请选择性别',
        		              triggerAction : 'all',
        		              selectOnFocus : true,
        		              hiddenName:'sexType'
}
]},{
	columnWidth : .5, // 该列有整行中所占百分比
           layout : "form",
           items : [{
        	   xtype: 'datefield',
   			id: 'birthDate', 
   			name: 'birthDate', 
   			fieldLabel: '出生日期',
   			allowBlank : false,
            blankText:'请填出生日期',
   			allowBlank: true,
   			editable:false,  
   			format : 'Y-m-d' ,
   			width: 200
}
]} 
]},
{
layout:"column",
items:[{
	columnWidth : .5, // 该列有整行中所占百分比
           layout : "form",
           items : [{
        	   xtype: 'combo', 
      		 id : "grade",
      		              store :addGradeStore,
      		              fieldLabel: '最高学历',
      		              valueField : 'code',
      		              displayField : 'name',
      		              typeAhead : true,
      		              width: 200,
      		              mode:'remote', 
      		              emptyText : '请选择最高学历...',
      		              editable: false,
      		              triggerAction : 'all',
      		              selectOnFocus : true,
      		              hiddenName:'grade'
}
]},{
	columnWidth : .5, // 该列有整行中所占百分比
           layout : "form",
           items : [{
        	   xtype: 'combo', 
      		 id : "degree",
      		              store :addDegreeStore,
      		              fieldLabel: '最高学位',
      		              valueField : 'code',
      		              displayField : 'name',
      		              typeAhead : true,
      		              width: 200,
      		              mode:'remote', 
      		              emptyText : '请选择最高学位...',
      		              editable: false,
      		              triggerAction : 'all',
      		              selectOnFocus : true,
      		              hiddenName:'degree'
}
]} 
]},

{
	layout:"column",
	items:[{
		columnWidth : .5, // 该列有整行中所占百分比
	           layout : "form",
	           items : [{
	        	   xtype: 'textfield', 
	       		id:'zipAdd',
	       		name: 'zipAdd', 
	       		fieldLabel: '通讯地址', 
	       		width: 200
	}
	]},{
		columnWidth : .5, // 该列有整行中所占百分比
	           layout : "form",
	           items : [{
	        	   xtype: 'textfield', 
	       		id:'houseAdd',
	       		name: 'houseAdd', 
	       		fieldLabel: '住宅地址', 
	       		width: 200
	}
	]} 
	]},

{
layout:"column",
items:[{
	columnWidth : .5, // 该列有整行中所占百分比
           layout : "form",
           items : [{
        	   xtype: 'textfield', 
       		id:'zipcode',
       		name: 'zipcode', 
       		fieldLabel: '邮政编码', 
       		width: 200  
}
]},{
	columnWidth : .5, // 该列有整行中所占百分比
           layout : "form",
           items : [{
        	   xtype: 'textfield', 
          		id:'worktel',
          		name: 'worktel', 
          		fieldLabel: '单位电话', 
          		width: 200  
}
]} 
]},

{
layout:"column",
items:[{
	columnWidth : .5, // 该列有整行中所占百分比
           layout : "form",
           items : [{
        	   xtype: 'textfield', 
         		id:'cellPhoneNo',
         		name: 'cellPhoneNo', 
         		fieldLabel: '手机号码', 
         		width: 200  
}
]},{
	columnWidth : .5, // 该列有整行中所占百分比
           layout : "form",
           items : [{
        	   xtype: 'textfield', 
        		id:'emailAdd',
        		name: 'emailAdd', 
        		fieldLabel: '电子邮箱', 
        		width: 200  
}
]} 
]},

{
layout:"column",
items:[{
	columnWidth : .5, // 该列有整行中所占百分比
           layout : "form",
           items : [{
        	   xtype: 'combo', 
        		 id : "mstatus",
        		              store :addMstatusStore,
        		              fieldLabel: '婚姻状况',
        		              valueField : 'code',
        		              displayField : 'name',
        		              typeAhead : true,
        		              width: 200,
        		              mode:'remote', 
        		              emptyText : '请选择婚姻状况...',
        		              allowBlank : false,
        		              blankText:'请选择婚姻状况',
        		              editable: false,
        		              triggerAction : 'all',
        		              selectOnFocus : true,
        		              hiddenName:'mstatus'
}
]},{
	columnWidth : .5, // 该列有整行中所占百分比
           layout : "form",
           items : [{
      	xtype: 'textfield', 
		id:'mateName',
		name: 'mateName', 
		fieldLabel: '配偶姓名', 
		width: 200
}
]} 
]},

{layout:"column",
items:[{
	columnWidth : .5, // 该列有整行中所占百分比
           layout : "form",
           items : [{
        	   xtype: 'textfield', 
       		id:'matework',
       		name: 'matework', 
       		fieldLabel: '配偶工作单位', 
       		width: 200
}
]},{
	columnWidth : .5, // 该列有整行中所占百分比
           layout : "form",
           items : [{
        	   xtype: 'textfield', 
          		id:'matetel',
          		name: 'matetel', 
          		fieldLabel: '配偶联系电话', 
          		width: 200
}
]} 
]},

{layout:"column",
	items:[{
		columnWidth : .5, // 该列有整行中所占百分比
	           layout : "form",
	           items : [{
	        	   xtype: 'textfield', 
	        		id:'hrAdd',
	        		name: 'hrAdd', 
	        		fieldLabel: '户籍地址', 
	        		width: 200
	}
	]},{
		columnWidth : .5, // 该列有整行中所占百分比
	           layout : "form",
	           items : [{
	        		
	        		   xtype: 'textfield', 
	   	       		id:'resideAdd',
	   	       		name: 'resideAdd', 
	   	       		fieldLabel: '居住地址', 
	   	       		width: 200
	}
	]} 
	]},
	
	{layout:"column",
		items:[{
			columnWidth : .5, // 该列有整行中所占百分比
	        layout : "form",
	        items : [{
	        	xtype: 'textarea', 
				id:'resideState',
				name: 'resideState', 
				fieldLabel: '居住状况', 
				width: 200
	        	
	        }]
	    },{ 
	    	columnWidth : .5, // 该列有整行中所占百分比
	        layout : "form",
	        items : [{
	        	xtype: 'datefield',
	        	id: 'relationshipDate', 
	        	name: 'relationshipDate', 
	        	fieldLabel: '与我行建立信贷关系时间',  
	        	allowBlank: true, 
	        	editable:false, 
	        	width:200 ,
	        	format : 'Y-m-d'
	        }]
	    }]
	},
	
	{layout : "form",
		items : [	{ 
			xtype: 'combo', 
        	id : "isPeasant",
            store :yesOrNoStore,
            fieldLabel: '是否农户',
            valueField : 'code',
            displayField : 'name',
            emptyText : '请选择是否...',
            allowBlank : false,
            blankText:'请选择是否',
            typeAhead : true,
            width: 200,
            mode:'remote',  
            hiddenName:'isPeasant',
            editable: false,
            triggerAction : 'all',
            selectOnFocus : true 
	}]},

	{     
        layout : 'column',     
        items : [{     
            columnWidth : .1 ,
            xtype:'label',
            text:'社会保障信息:',
        }, {     
            columnWidth : .1,     
            items : [new Ext.form.Checkbox({     
                boxLabel : '养老保险',  
                name : 'socialSecurity1',
                inputValue :1,     
                checked : false    
            })]     
        }, {     
            columnWidth : .1,     
            items : [new Ext.form.Checkbox({     
                boxLabel : '失业保险',  
                name : 'socialSecurity2',
                inputValue :1,
                checked : false    
            })]     
        }, {     
            columnWidth : .1,     
            items : [new Ext.form.Checkbox({     
                boxLabel : '工伤保险',  
                name : 'socialSecurity3',
                inputValue :1,
                checked : false    
            })]     
        }, {     
            columnWidth : .1,     
            items : [new Ext.form.Checkbox({     
                boxLabel : '医疗保险',  
                name : 'socialSecurity4',
                inputValue :1,
                checked : false    
            })]     
        }, {     
            columnWidth : .1,     
            items : [new Ext.form.Checkbox({     
                boxLabel : '生育保险',  
                name : 'socialSecurity5',
                inputValue :1,
                checked : false    
            })]     
        }, {     
            columnWidth : .1,     
            items : [new Ext.form.Checkbox({     
                boxLabel : '住房公积金',  
                name : 'socialSecurity6',
                inputValue :1,
                checked : false    
            })]     
        }, {     
            columnWidth : .1,     
            items : [new Ext.form.Checkbox({     
                boxLabel : '无',  
                name : 'socialSecurity7',
                inputValue :1,
                checked : false    
            })]     
        }, {     
            columnWidth : .2,     
                
        }]     
    }

	

] 
}],
buttonAlign:'right',
buttons: 
[  

{ text: '保存', handler: editFunction } ,
{ text: '下一步', handler: editFunctionAndNext }

] 
});


//表单加载数据
addForm.form.load({  
    waitMsg : '正在加载数据请稍后',
    waitTitle : '提示',
    url : 'customer/getIndGeneral.do', 
    method:'post',
    success:function(form,action){
    	
    },  
    failure:function(form,action){
     Ext.Msg.alert('提示','数据加载失败');  
    }  
});

function editFunction(){

	if(addForm.form.isValid()){
		addForm.form.doAction('submit', { 
			url : 'customer/editIndGeneral.do?isOperation=0', 
			method : 'post', 
			success : function() {
				Ext.Msg.alert('提示', '保存成功！'); 
			}, 
			failure : function() { 
				Ext.Msg.alert('提示', '保存失败！'); 
			} 
		}); 
	}
	
}

function editFunctionAndNext(){
	if(addForm.form.isValid()){
		addForm.form.doAction('submit', { 
			url : 'customer/editIndGeneral.do?isOperation=0', 
			method : 'post', 
			success : function() {
				Ext.Msg.confirm("Confirm",'保存成功，是否继续添加职业信息',function(bool){
					if(bool=='yes'){
						window.location.href = "view/customer/Customer_IndOccupation.jsp";
						return true;
					}
					else{
						return false;	
					}
				}); 
				//alert("成功");
				
			}, 
			failure : function() { 
				Ext.Msg.alert('提示', '保存失败！'); 
			} 
		}); 
	}
}
       
}); 